/*
********************************************************************************
* Copyright (C) 2021, xiang.D <dx_65535@163.com>.
* All right reserved.
*
* File Name   : simple_factory.cc
* Author      :
* Version     : V1.0
* Description :
* Journal     : 2021-10-10 init v1.0
* Brief       : Blog: https://blog.csdn.net/qq_38750572?spm=1001.2014.3001.5343
* Others      :
********************************************************************************
*/
#include <iostream>

using namespace std;

typedef enum
{
    HW_MATE = 0x1001,
    HW_NOVA,
    HW_P,
} EPhoneType;

/* Phone abstract interface */
class CPhone
{
public:
    virtual ~CPhone(){}

    /* Function interface for phone */
    virtual void showLabel() = 0;
    virtual void call() = 0;
    virtual void takePicture() = 0;
    virtual void messages() = 0;
};

class CHwMate : public CPhone
{
public:

    void showLabel()
    {
        cout << "Welcome Mate Serial!" << endl;
    }

    void call() {}
    void takePicture() {}
    void messages() {}
};

class CHwNova : public CPhone
{
public:

    void showLabel()
    {
        cout << "Welcome Nova Serial!" << endl;
    }
    void call() {}
    void takePicture() {}
    void messages() {}
};

class CHwP : public CPhone
{
public:

    void showLabel()
    {
        cout << "Welcome P Serial!" << endl;
    }
    void call() {}
    void takePicture() {}
    void messages() {}
};

class CHuaWeiBusiness
{
public:

    CPhone *getPhoneInstance(EPhoneType type)
    {
        switch (type) {
          case HW_MATE:
            return new CHwMate();
          break;

          case HW_NOVA:
            return new CHwNova();
          break;

          case HW_P:
            return new CHwP();
          break;

          default:
            return NULL;
        }
    }

};

int main(int argc, char *argv[])
{
    CHuaWeiBusiness theHuaWeiBusiness;

    CPhone *theMatePhone =  theHuaWeiBusiness.getPhoneInstance(HW_MATE);
    if (NULL != theMatePhone) {
        theMatePhone->showLabel();
        delete theMatePhone;
    } else {
        cout << "theMatePhone is null!" << endl;
    }

    CPhone *theNovaPhone =  theHuaWeiBusiness.getPhoneInstance(HW_NOVA);
    if (NULL != theNovaPhone) {
        theNovaPhone->showLabel();
        delete theNovaPhone;
    } else {
        cout << "theNovaPhone is null!" << endl;
    }

    CPhone *thePPhone =  theHuaWeiBusiness.getPhoneInstance(HW_P);
    if (NULL != thePPhone) {
        thePPhone->showLabel();
        delete thePPhone;
    } else {
        cout << "thePPhone is null!" << endl;
    }

    return 0;
}

